'use client';

import { usePathname } from 'next/navigation';
import { NavigationProvider } from '@/contexts/NavigationContext';
import ClientLayout from '@/components/ClientLayout';

interface ConditionalLayoutProps {
  children: React.ReactNode;
}

export const globalsData = {
  data: null,
  // 这里可以定义全局的状态或数据
};

// 为 /manage 路由创建一个简化的布局组件
function ManageLayout({ children }: { children: React.ReactNode }) {
  return (
    <div className="relative min-h-screen w-full overflow-x-hidden bg-[#f1ebdb]">
      <main className='min-h-[800px]'>
        {children}
      </main>
    </div>
  );
}

export default function ConditionalLayout({ children }: ConditionalLayoutProps) {
  const pathname = usePathname();

  // 如果路由是 /manage，则使用简化的布局，不需要 NavigationProvider
  if (pathname === '/manage' || pathname === "/api-docs") {
    return <ManageLayout>{children}</ManageLayout>;
  }

  // 其他路由使用 NavigationProvider 和完整的 ClientLayout
  return (
    <NavigationProvider>
      <ClientLayout>
        {children}
      </ClientLayout>
    </NavigationProvider>
  );
}
